package com.config;


import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.util.StringUtils;

@Configuration
@PropertySource(value = {"classpath:application.yml"})
@ConfigurationProperties(prefix = "spring.redis")
public class RedissonConfig {
    @Value("${database}")
   private Integer database;
    @Value("${havePassword}")
    private String havePassword;
    @Value("${host}")
    private String host;
    @Value("${password}")
    private String password;
    @Value("${port}")
    private Integer port;
    @Value("${timeout}")
    private String timeout;




    @Bean
    public RedissonClient redissonClient(){
        Config config = new Config();
        SingleServerConfig singleServerConfig = config.useSingleServer().setAddress("redis://" + host + ":" + port).setDatabase(database);



        return Redisson.create(config);
    }
}
